grammar tscn;

file: section+;
// section
section: section_header property_*;

// [gd_scene load_steps=10 format=2] [node name="main" type="Node"]
section_header: '[' ID attribute+ ']';
attribute: ID '=' value;

// ?覆盖的可能性?
INT: SIGN? DIGIT+;
DIGIT: [0-9];

// property script = ExtResource( 1 ) 0/texture = ExtResource( 2 )
property_: ID '=' value;
// instance(p1,p2);
instance: ID '(' value (',' value)* ')';
// { "key1' : v1 , 'key2' : v2 }
dictionary: '{' pair (',' pair)* '}';
pair: STRING_ ':' value;
// [ v1, v2, v3 ]
array: '[' value (',' value?)*  ']';

value:
	INT
	| FLOAT_
	| STRING_
	| dictionary
	| array
	| instance
	| 'true'
	| 'false'
	| 'null';

// ID
ID: NameStartChar NameChar*;
NameChar: NameStartChar | '/';
NameStartChar: CHAR | '_' | DIGIT;
fragment CHAR: ('a' ..'z' | 'A' ..'Z');

// String
STRING_: '"' ~["]* '"';
// Hex 
HEX: '-'? '0x' HEXNUM (HEXNUM | '_')*;
HEXNUM: [a-fA-F0-9];
// Bin
BIN: '-'? '0b' BINNUM (BINNUM | '_')*;
BINNUM: '0' | '1';
// Number
FLOAT_: SIGN? INT '.' INT;
SIGN: ('+' | '-');



WS: (' ' | '\r' | '\n' | '\t') -> skip;